package com.desktopmng.orm;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.apache.commons.lang.builder.EqualsBuilder;

@SuppressWarnings("serial")
@MappedSuperclass
public class BaseEntity extends BaseObject{
	/**
	 * Hibernate optismic lock 
	 */
    @Version
    @Column(name = "VERSION")
    private int version = 0;
	
    
    @Temporal(TemporalType.TIMESTAMP)
/*    @org.hibernate.annotations.Generated(
    		org.hibernate.annotations.GenerationTime.INSERT
    )*/
    @Column(name="CREATED", nullable = false, updatable = false)
    private Date created = new Date();
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="LAST_MODIFIED", nullable = false)
    private Date lastModified ;

    
	public Date getCreated() {
		return created;
	}

	
	public Date getLastModified() {
		return lastModified;
	}

	public int getVersion() {
		return version;
	}

	public void setCreated(Date created) {
		this.created = created;
	}


	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}

	public void setVersion(int version) {
		this.version = version;
	}


	@Override
	public boolean equals(Object o) {
		return EqualsBuilder.reflectionEquals(this.hashCode(), o.hashCode());
	}
}
